package com.briup.mt.web.controller;


import com.briup.mt.bean.BaseFile;
import com.briup.mt.service.IBaseFileService;
import com.briup.mt.utils.Message;
import com.briup.mt.utils.MessageUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Validated
@RequestMapping("/base_file")
public class BaseFileController {
    @Autowired
    private IBaseFileService baseFileService;

    @GetMapping("query")
    public Message query(String id,String filename){
        List<BaseFile> list = baseFileService.qurey(id,filename);
        return MessageUtil.success(list);
    }


    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(BaseFile info){
        baseFileService.saveOrUpdate(info);
        return MessageUtil.success("操作成功");
    }

    @DeleteMapping("deleteById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "用户编号",required = true,paramType = "query"),
    })
    public Message deleteById(@NonNull String id){
        baseFileService.deleteById(id);
        return MessageUtil.success("操作成功");
    }
}
